﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>MenuLinkAddressSelect</title>
    <script src="~/Scripts/jquery-easyui-1.4.4/jquery.min.js"></script>
    <script src="~/Scripts/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
    <script src="~/Scripts/jquery-easyui-1.4.4/locale/easyui-lang-zh_CN.js"></script>
    <script src="~/Content/js/common.js"></script>
    <link href="~/Content/themes/icon.css" rel="stylesheet" />
    <link href="~/Scripts/jquery-easyui-1.4.4/themes/bootstrap/easyui.css" rel="stylesheet" />
    <link href="~/Content/themes/table.css" rel="stylesheet" />
    <style type="text/css">
        .owin {
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            display:none;
            z-index: 999;
            background: white;
            padding: 10px;
            overflow: auto;
            box-sizing: border-box;
        }

            .owin li {
                line-height: 30px;
                padding-left: 10px;
            }

                .owin li:hover {
                    background-color: #f7f7f7;
                    color: gold;
                    cursor: pointer
                }

            .owin i {
                margin-right: 5px;
            }

        #iconsHtml i {
            display: inline-block;
            width: 25px;
            height: 25px;
            margin: 5px;
            border: 1px solid transparent;
            text-align: center;
            font-size: 18px;
            line-height: 25px;
        }

            #iconsHtml i:hover {
                border-color: #ddd;
                background: #f7f7f7;
                cursor: pointer;
            }

        #iconCls {
            font-size: 16px;
            width: 20px;
            text-align: center;
            display: inline-block;
            position: absolute;
            left: 15px;
            top: 10px;
            z-index: 99
        }
    </style>
</head>
<body>
    <div id="fileHtml" class="owin" style="padding: 0 0 0 0;">
        <div class="datagrid-toolbar" style="position: fixed; top: 0; left: 0; right: 0 ">
            <a class="easyui-linkbutton" data-options="iconCls:'fa fa-home'" plain="true" id="btnHome" onclick="getFiles('/')">主目录</a>
            <div class="btn-separator"></div>
            <a class="easyui-linkbutton" data-options="iconCls:'fa fa-undo'" plain="true" id="btnClose" onclick="$('#fileHtml').hide()">关闭</a>
        </div>
        <ul></ul>
    </div>

    <script type="text/javascript">
        function getFiles(path) {
            console.log(path+"------------");
            $.ajax({
                //请求当前用户可以操作的按钮
                url: "/Menu/GetLinkAddressFiles",
                type: "post",
                data: { "path": path },
                dataType: "json",
                timeout: 5000,
                success: function (data) {
                    console.log(data);
                    var html = [];
                    for (var i = 0; i < data.length; i++) {
                        var li = data[i];
                        if (li.Type) {
                            //var files = '<li onclick="getFiles(/' + li.FullName.toString() + ')">' + li.Name + '</li>';
                            //var files = '<li onclick="getFiles(\'${2}\')" >{1}</li>'.format(li.Name, li.FullName);
                            var files = format("<li onclick=getFiles(\'${2}\') >{1}</li>", li.Name, li.FullName);
                            html.push(files);
                        }
                        else {
                            var title = "<li onclick='getTitle(/" + li.FullName.toString() + ")'>" + li.Name + "</li>";
                            html.push(title);
                        }
                    }
                    $("#fileHtml ul").html(html.join(''));
                }
            })
        }
        function getTitle(path) {
            console.log(path + "+++++++++++++++++");
            $.ajax({
                url: "/Menu/GetLinkAddressFileTitle",
                type: "post",
                data: { "path": path },
                dataType: "json",
                timeout: 5000,
                success: function (data) {
                    $("#Url_path").textbox("setValue", path);
                    $("#Priv_name").textbox("setValue", data.Msg);
                }
            });
        }
        </script>
</body>
</html>
